
#文件逐行读取（读取就结束后光标会移动到下一行的位置）
'''
fp = open('D:/testtest.txt','r+',encoding='gbk') # r+ 能读能写
print(fp.readable()) # 文件是否可读
print('第一行',fp.readline(),end=' ')
print('第二行',fp.readline(),end=' ')
print('第三行',fp.readline(),end=' ') # 读取单行、遇到空格结束、文件读取光标移动
fp.close()
# print('>>>>>>>>>>>')
fp1= open('D:/test.txt','r',encoding='gbk')
print(fp1.readlines())   # 读取文件所有信息放在一个列表中
fp1.close()
'''
'''
#  "a" 写在文件最后 追加在文件最后

fp2=open('D:/sici.txt','a',encoding='gbk')
fp2.write('测试测试,l;kfdsk',)
fp2.write('《送僧归日本》\n唐代：钱起\n上国随缘住，来途若梦行。\n浮天沧海远，去世法舟轻。\n水月通禅寂，鱼龙听梵声。\n惟怜一灯影，万里眼中明。')
fp2.close()

# @方法一@ 读取所有的行的内容写入另一个文件中
src_f0 = open('D:/testtest.txt','r+',encoding='gbk')
date=src_f0.readlines() # 读取到的是列表
print(date)
src_f0.close()
dst_f= open('D:/OtherToOther.txt','a',encoding='gbk')
dst_f.write(str(date))# 写入是必须是字符串
dst_f.write(date[3])  # 写入文件的特定行的内容
dst_f.close()
# 方法二 读取一个文件中的所有内容写入另一个文件中 write
H =open('D:/testtest.txt','r+',encoding='gbk')
date1 =H.read()
W =open('D:/OtherToOther.txt','a',encoding='gbk')
W.write(date1)
H.close()
W.close()

# 方法三 读取一个文件中的所有内容写入另一个文件中 writelines()
M =open('D:/testtest.txt','r+',encoding='gbk')
date0 =M.readlines()
N =open('D:/OtherToOther.txt','a',encoding='gbk')
N.writelines(date0)
M.close()
N.close()

# 方法三 打开操作后会自动关闭
with open('D:/testtest.txt', 'r+', encoding='gbk') as src_f,\
open('D:/OtherWriteToOther.txt','w',encoding='gbk') as dst_f:
        date= src_f.writelines()
        dst_f.write(date)

# rb  一二进制处理文件、对Linux无作用
# w+打开文件就清空

# src_f=open('D:/testtest.txt', 'r+', encoding='gbk')
# # print(src_f.closed)
# # print(src_f.seek(2))
# # print(src_f.tell()) # 光标的位置、除了read()方法、其他都是字节移动
# src_f.truncate(250)  # 截取文件
# print('>>>>>>>>>>>>>>>>')
# print(src_f.read())
# print(src_f.readline())
# print(src_f.encoding)
# print(src_f.seekable())# 光标移动
'''
# 迭代器和递归
'''
str='mfklsf'
l=[64,1,2,5,2,5]
# 迭代器机制
# l0_iter=l.__iter__()
# print(l0_iter.__next__())
# print(l0_iter.__next__())
# print(l0_iter.__next__())
# print(l0_iter.__next__())
# print(l0_iter.__next__())
# print(l0_iter.__next__())
for i in l:
    print(i)
index=0
while index <len(l):
    print(l[index])
    index +=1

w={1,1,2,3,45,6,8,45,545,454,85,85}

w0=w.__iter__()
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print(w0.__next__())
print('>>>>>>>')
dict1={'aa':1515,'bb':2,'cc':5}
for k in dict1:  # for 调用dict1中的iter()方法、调用next方法并且捕捉到StopIteration异常后遍历
    print(k)
print('<<<<<<<<<<<<<<')
dict10=dict1.__iter__()
print(dict10.__next__(),end=' ')
print(dict10.__next__(),end=' ')
print(dict10.__next__(),end=' ')
print(dict10.__next__(),end=' ')
print(dict10.__next__(),end=' ')
print(dict10.__next__(),end=' ')
print('>>>>>>>>>>>>>')
# iter_test=str.__iter__()
# print(iter_test.__next__())
# print(iter_test.__next__())
# print(iter_test.__next__())
# print(iter_test.__next__())
# print(iter_test.__next__())
# print(iter_test.__next__())
# print(iter_test.__next__())
'''
# 生成器 函数
# ll=['qq','qq1','qq11']
# iter_ll=ll.__iter__()
# print(iter_ll.__next__())
# print(iter_ll.__next__())
# print(iter_ll.__next__())
# print(iter_ll.__next__())
# print(next(iter_ll))   # next 就是调用iter_ll.__next__()

# def consumer(name):
#     print('我是%s,')
#     while True:
#         str1= yield
#         print('%s开始%s' %(name,str1))
#
# def product():
#     c1=consumer("张三")
#     c1.__next__()
#     c2=consumer('李四')
#     c2.__next__()
#     for i in range(10):
#         c1.send("测试 %d" %i)
#         c2.send("性能测试 %d" %i)
# product()

# def function(s,indext):
#     for i in range(1,100):
#         if i % 3==0 and i % 7==0:
#             s +=i
#             indext=indext + 1
#     print(s,indext)
#     return s,indext
# function(s=0,indext=0)
#
# l1=[25,15,45,156,'google']
# l10=[2,15,15,5,25,152,'百度']
# l1.extend(l10)
# print(l1)
# print(set(l1))
#
# m='jkcsjadfsdsjdfkjdsdf'
# H='GJSAHGSDFSKJGSJ'
# print(m.upper())
# print(H.lower())
# print(m.capitalize())
# print(m.count('s'))
# m0='HmklmGmkjIjoijG'
# c=0
# d=0
# for ii in m0:
#     if ii.islower():
#         c=c+1
#     else:
#         d+=1
# print("小写字母个数%d，大写字母个数%d" %(c,d))
#
# def f(name,age,sex='男'):
#     return name,age,sex
#
# f('张三',12,'女')
#
# def  ff(x,*y,**z):
#     print(x,z,y)
#
# ff(1,2,3)
# def  ff0(x,*y,**z):
#     print(x,z,y)
#
# ff(1,name='zhangsan',age=6)
# ff(1,[1,5,15,254])
# ff(*[2515,15,15,465,],{'age': 50, 'name': 'dfsfs'})
# ff(*[1,2,4,2,5],name='dfsfs',age=50)
#
#
# def fun1(x=1,*y,**z):
#     print(x,y,z)
#     return y
#     print(x)
#
# def fun2(arg):
#     ret =fun1(name=arg)
#     print(ret)
# fun2('张三')
#
# b='sdfsdf  %d %%'%12
# print(b)
#
# s='老男孩'
# bytes(s,'utf-8')
# s.encode('utf-8')
#
#
# a=["zhang",1,2,3,4,5]
# b=('san',1,2,3,4,5)
# d=["shi",1,522,3,6,69]
# p='_'.join((list(zip(a,b,d)))[0])
# print(p)
#
#
#
# # strip()  去掉字符串开始的换行以及空格
# x ="jfkashasjf kjs>>>>>>>>>>>>>>>>"
# print(x.strip('>'))
#
# import os
# print(os.getcwd())
# os.makedirs('osstandy/ostest') # 创建文件
# os.removedirs('osstandy/ostest')
# # 删除文件、上级文件中判断是否为空、为空则一切删除
# # os.chdir()
#
# y="重庆科技"
# L=[]
# c = ".*".join([y [ i : min(i+1,len(y))] for i in range(0,len(y),1)])
# L.append(c)
# print(c)
import  requests ,random,json,time

url="http://113.207.120.119:81/auth/api/getProjece/Unitinfo/1.0"
r=requests.put(url,
# json={"uid":random.randint(10000,999999),
#                          # "Access Token":"0ac0ad47-2770-4b07-9159-f28a15093e62",
#                          # "token_type":"bearer",
#                          # "expires_in":"39168",
#                          "high_tech_area":random.randint(1,4),
#                          "storage_date":time.time()
                        data={
                        'dwmc':'单位名称1',
                        'txdz':'办公地址1',
                        'dwszd':345234,
                        'fddbrxm':'法定代表人姓名1',
                        'fddbrsfz':'法定代表人证件号1',
                        'xymldm':43534534,
                        'gszcdjlx':5463453453,
                        'zczb':43534,
                        'ucs':'社会统一信用代码',
                        'clrq':35253,
                        'jyfw':'业务范围(对应公司简介)',
                        'lxrxm':'单位联系人姓名',
                        'yddh':1241323123,
                        'bgdh':324231423,
                        'email':'134@12.com',
                        'khyx':'4323423',
                        'hm':'4234',
                        'yxzh':23423,
                        'sfsbxm':'s',
                        'high_tech_area':1,
                        'storage_date':4354323424,
                         },
                   headers={"Content-Type":"application/x-www-form-urlencoded",
                            "Access Token": "0ac0ad47-2770-4b07-9159-f28a15093e62",
                            "token_type": "bearer",
                            "expires_in": "39168",
                            })

result=r.json()
print(result)
